package com.smh.util;

import java.util.ArrayList;
import java.util.Random;

public class CodeUtil {
    private CodeUtil(){

    }
    public static String getCode(){
        ArrayList<Character> list = new ArrayList<>();
        for (int i = 0; i < 26; i++) {
            list.add((char) ('A'+i));
        }
        for (int i = 0; i < 26; i++) {
            list.add((char) ('a'+i));
        }
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < 4; i++) {
            int index = random.nextInt(list.size());
            sb.append(list.get(index));
        }
        int num = random.nextInt(10);
        int index = random.nextInt(sb.length()+1);
        sb.insert(index,num);
        return sb.toString();
    }
}
